
def singleton(cls):
	instances = {}
	def wrapper():
		if cls not in instances:
			instances[cls] = cls()
		return instances[cls]
	return wrapper

@singleton
class MyClass:
	def __init__(self):
		self.num = 0


if __name__ == '__main__':
	c1 = MyClass()
	print c1.num
	c2 = MyClass()
	c2.num = 1
	print c1.num
	print (c1 == c2)
